﻿namespace WMS6.Web.OrderManagement
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.UserControls;

    public class PurchaseOrderQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlExternOrderID;
        protected DropDownList ddlOwnerID;
        protected DropDownList ddlPoDate;
        protected DropDownList ddlPoID;
        protected DropDownList ddlPoTypeOper;
        protected DropDownList ddlStatusOper;
        protected DropDownList ddlVendorID;
        protected DropDownList ddlVendorName;
        protected DropDownList ddlVendorRef;
        protected HtmlForm F3010;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlImage img2;
        protected Label lblExternOrderID;
        protected Label lblOwnerID;
        protected Label lblPoDate;
        protected Label lblPoID;
        protected Label lblPoType;
        protected Label lblStatus;
        protected Label lblSys_Code;
        protected Label lblVendorID;
        protected Label lblVendorName;
        protected Label lblVendorRef;
        protected MultipleSelectControl MSCPoType;
        protected MultipleSelectControl MSCStatus;
        protected HtmlLink mycss;
        protected TextBox txtExternOrderID;
        protected TextBox txtOwnerID;
        protected TextBox txtPoDate;
        protected TextBox txtPoDate2;
        protected TextBox txtPoID;
        protected TextBox txtVendorID;
        protected TextBox txtVendorName;
        protected TextBox txtVendorRef;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("PurchaseOrderList.aspx?action={0}&from='list'", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("PurchaseOrderList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.hdnActionID.Value = base.Request.QueryString["action"].ToString();
            }
        }

        private void LoadDLL()
        {
            base.InitQueryDDL(this.ddlPoID, 0);
            base.InitQueryDDL(this.ddlStatusOper, 0);
            base.InitQueryDDL(this.ddlOwnerID, 0);
            base.InitQueryDDL(this.ddlPoDate, 1);
            base.InitQueryDDL(this.ddlPoTypeOper, 0);
            base.InitQueryDDL(this.ddlVendorID, 0);
            base.InitQueryDDL(this.ddlVendorName, 0);
            base.InitQueryDDL(this.ddlVendorRef, 0);
            base.InitQueryDDL(this.ddlExternOrderID, 0);
            base.BindData2DDLBySysCode(this.MSCPoType, "POType");
            this.ddlPoTypeOper.SelectedValue = "One Of";
            base.BindData2DDLBySysCode(this.MSCStatus, "POStatus");
            this.ddlStatusOper.SelectedValue = "One Of";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDLL();
                this.LoadData();
            }
        }

        public string ExternalPoID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternOrderID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternOrderID.Text.Trim(), this.ddlExternOrderID.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerID.SelectedValue);
                }
                return "";
            }
        }

        public string PoDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPoDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPoDate.Text.Trim(), this.ddlPoDate.SelectedValue, this.txtPoDate2.Text.Trim(), "PoDate");
                }
                return "";
            }
        }

        public string PoID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPoID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPoID.Text.Trim(), this.ddlPoID.SelectedValue);
                }
                return "";
            }
        }

        public string PoType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCPoType.ReturnValue))
                {
                    return base.GetParamsString(this.MSCPoType.ReturnValue, this.ddlPoTypeOper.SelectedValue);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCStatus.ReturnValue))
                {
                    return base.GetParamsString(this.MSCStatus.ReturnValue, this.ddlStatusOper.SelectedValue);
                }
                return "";
            }
        }

        public string VendorID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorID.Text.Trim(), this.ddlVendorID.SelectedValue);
                }
                return "";
            }
        }

        public string VendorName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorName.Text.Trim(), this.ddlVendorName.SelectedValue);
                }
                return "";
            }
        }

        public string VendorRef
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorRef.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorRef.Text.Trim(), this.ddlVendorRef.SelectedValue);
                }
                return "";
            }
        }
    }
}

